import vite from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
import path from 'path'

export default vite.defineConfig({
    plugins: [
        vue(),
        styleImport({
            libs: [{
                libraryName: 'element-plus',
                esModule: true,
                ensureStyleFile: true,
                resolveStyle: (name) => {
                    name = name.slice(3)
                    console.log(name);
                    return `element-plus/packages/theme-chalk/src/${name}.scss`;
                },
                resolveComponent: (name) => {
                    console.log(name);
                    return `element-plus/lib/${name}`;
                },
            }]
        })
    ],
    resolve: {
        alias: {
            '~': path.resolve(__dirname, './'),
            '@': path.resolve(__dirname, './src/'),

        }
    },
    server: {
        proxy: {
            '/api': {
                target: 'http://www.codeman.ink:3000',
                changeOrigin: true,
                rewrite: path => path.replace(/^\/api/, '')
            },

        }
    }
})